package com.ygxsk.carhome.ui.livefee;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.gyf.immersionbar.ImmersionBar;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.constant.ConstantApi;
import com.ygxsk.carhome.constant.ConstantSign;
import com.ygxsk.carhome.constant.ExtraKey;
import com.ygxsk.carhome.enumwrap.FeeLiveOtherType;
import com.ygxsk.carhome.enumwrap.FeeLiveReceiptClassify;
import com.ygxsk.carhome.listener.DoubleClickListener;
import com.ygxsk.carhome.listener.ErrorParentExtraSingle;
import com.ygxsk.carhome.response.PaymentNotesBean;
import com.ygxsk.carhome.response.PaymentNotesOutsideBean;
import com.ygxsk.carhome.response.PropertyPaymentBean;
import com.ygxsk.carhome.retrofit.AddLogUpLoadInfo;
import com.ygxsk.carhome.retrofit.ApiException;
import com.ygxsk.carhome.retrofit.ApiRequestSubListener;
import com.ygxsk.carhome.retrofit.ApiService;
import com.ygxsk.carhome.retrofit.ErrorConsumer;
import com.ygxsk.carhome.retrofit.NetworkManager;
import com.ygxsk.carhome.retrofit.ResponseTransformer;
import com.ygxsk.carhome.ui.ErrorActivity;
import com.ygxsk.carhome.ui.adapter.PaymentNotesAdapter;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.views.MyLinearLayoutManager;
import com.ygxsk.integrated.retrofit.Parameterkey;

import java.util.ArrayList;
import java.util.HashMap;

import butterknife.BindView;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023/12/25  14:28
 * @Description:物业缴费的历史记录,租赁费的缴费记录 通用一个页面
 */
public class PaymentNotesActivity extends ErrorActivity implements ErrorParentExtraSingle {

    @BindView(R.id.refreshLayoutInPaymentFeeNotes)
    SmartRefreshLayout refreshLayoutInPaymentFeeNotes;

    @BindView(R.id.recyclerviewinpaymentfeenotes)
    RecyclerView recyclerViewInPaymentFeeNotes;

    /**
     * 最后一条上传的缴费记录的id信息
     */
    private String receiptIdPass;

    //填充缴费记录的适配器
    private PaymentNotesAdapter paymentNotesAdapter;

    /**
     * 装在缴费记录的列表信息
     */
    private ArrayList<PaymentNotesBean> mDatasResources = new ArrayList<>();

    private int pagination_upLoad = Parameterkey.pageNum_default_first;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mActivityInstance = this;

        processExtraData();

        initloading();

        initViews();

        gainDatas();

    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_payment_notes;
    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();

        ImmersionBar.with(this)//
                .titleBar(R.id.toolbarygxskout)
                .fitsSystemWindows(true)//解决状态栏和布局重叠问题，任选其一，默认为false，当为true时一定要指定statusBarColor()，不然状态栏为透明色，还有一些重载方法
                //.statusBarColor(R.color.colorPrimary)//
                //.navigationBarColor(R.color.colorPrimary)//
                //.keyboardEnable(true)
                .init();

    }

    @Override
    protected void initToolBar(ToolbarHelper toolbarHelper) {

        toolbarHelper.setTitle(getString(R.string.pay_note_history));
        toolbarHelper.setVersionName(true, AppUtils.getAppVersionName());
        toolbarHelper.setLayoutClose(false, "", null);
        toolbarHelper.setLayoutLeft(true, R.drawable.backicon, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //搜索客户信息，优先关闭软键盘
                KeyboardUtils.hideSoftInput(mActivityInstance);
                methodBack();
            }
        });

        toolbarHelper.setLayoutRight(false, 0, "", null);


        //添加潜在客户的按钮
//        toolbarHelper.setLayoutRight(true, 1, "预约记录", new ClickUtils.OnDebouncingClickListener() {
//            @Override
//            public void onDebouncingClick(View v) {
//
//                //快速双加的限制，
//                Bundle extra_bundle = new Bundle();
//                ActivityUtils.startActivity(extra_bundle, RepairHistoryActivity.class);
//
//            }
//        });


    }

    @Override
    protected void onClickNodata(View v) {

        gainDatas();

    }

    @Override
    protected void initViews() {

        //setdatas
        recyclerViewInPaymentFeeNotes.setLayoutManager(new MyLinearLayoutManager(this));

        paymentNotesAdapter = new PaymentNotesAdapter(R.layout.paymentnotesadapter, mDatasResources);
        recyclerViewInPaymentFeeNotes.setAdapter(paymentNotesAdapter);
        paymentNotesAdapter.notifyDataSetChanged();


        paymentNotesAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {

                if (!DoubleClickListener.isFastDoubleClick()) {

                    PaymentNotesBean paymentNote = (PaymentNotesBean) adapter.getItem(position);

                    if (paymentNote != null) {

                        PropertyPaymentBean propertyPaymentBean = new PropertyPaymentBean();
                        //缴费方式
                        propertyPaymentBean.setPayTypeInfo(paymentNote.getPayTypeInfo());
                        //缴费时间
                        propertyPaymentBean.setPayTime(paymentNote.getPayTime());
                        //付款单号
                        propertyPaymentBean.setReceiptNo(paymentNote.getReceiptNo());
                        //费用总额TotalAmount确认过是使用这个字段。
                        propertyPaymentBean.setPayAmount(paymentNote.getTotalAmount());

                        String receiptId = paymentNote.getReceiptId();//用户获取详情用到?

                        //传递数据
                        Bundle bundle = new Bundle();
                        bundle.putString(ExtraKey.EXTRA_PAYMENT_RECEIPTID, receiptId);
                        //目的是为了填充实体 做列表
                        bundle.putParcelable(ExtraKey.EXTRA_PROPERTYPAYMENTBEAN, propertyPaymentBean);

                        //2024年2月5日13:43:11 区分是物业费还是租赁费，做标志携带.
                        bundle.putInt(ExtraKey.EXTRA_JUMPFROM_WHERE, flag_jumpfrom_where);

                        //付款详情界面
                        ActivityUtils.startActivity(bundle, PaymentDetailActivity.class);

                    }
                }

            }
        });

        refreshLayoutInPaymentFeeNotes.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {

            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {

                refreshLayout.getLayout().post(new Runnable() {
                    @Override
                    public void run() {

                        getServerDatas();

                        //保持原有
//                        getServerData(receiptIdPass);
                        refreshLayout.finishLoadMore();

                    }
                });

            }

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {

                refreshLayout.getLayout().post(new Runnable() {

                    @Override
                    public void run() {

                        //发起重新 查询条件 要重置为 从第一页查询,必须重置；
                        pagination_upLoad = Parameterkey.pageNum_default_first;

                        if (mDatasResources != null && !mDatasResources.isEmpty()) {
                            mDatasResources.clear();
                        }

                        if (paymentNotesAdapter != null) {
                            paymentNotesAdapter.notifyDataSetChanged();
                        }

                        getServerDatas();

                        refreshLayout.finishRefresh();

                    }
                });

            }
        });

    }

    @Override
    protected void gainDatas() {

        //清空原始数据
        if (mDatasResources != null && !mDatasResources.isEmpty()) {
            mDatasResources.clear();
        }

        if (paymentNotesAdapter != null) {
            paymentNotesAdapter.notifyDataSetChanged();
        }

        if (NetworkUtils.isConnected()) {

            getServerDatas();

        } else {
            netWorkError();
        }

    }

    private void getServerDatas() {

        //如果是物业缴费过来的，
        if (flag_jumpfrom_where == FeeLiveOtherType.TYPE_PROPERTY.getIndex()) {

            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "TYPE_PROPERTY-物业缴费");

//             enum FeeLiveReceiptClassify {
//                RECEIPT_CLASSIFY_WATER(1, "园区水费"),
//                RECEIPT_CLASSIFY_ELECTRIC(2, "园区电费"),
//                RECEIPT_CLASSIFY_PROPERTY(3, "物业费用");

            HashMap<String, Object> map = new HashMap<>();
            map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());
            map.put(Parameterkey.receiptClassify, FeeLiveReceiptClassify.RECEIPT_CLASSIFY_PROPERTY.getIndex());//物业费
//        map.put(Parameterkey.appointDate, appointDate_upLoad);
//        map.put(Parameterkey.appointDate, TimeUtils.date2String(TimeUtils.getNowDate(), TimeUtilSer.simplemore));

            AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
            addLogUpLoadInfo.setActivity(mActivityInstance);
            addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETRECEIPTLISTFORREMOTE_URL);//请求数字标识
            addLogUpLoadInfo.setUrlPath(ApiService.getReceiptListForRemote_url);//url地址
            addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
            addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
            addLogUpLoadInfo.setHashMapParameter(map);

            NetworkManager.getInstance().initRetrofitRxJava()
                    .create(ApiService.class)
                    .getReceiptListForRemote(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                            MediaType.parse(ApiService.HEADER_JSON)))
                    .compose(PaymentNotesActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                    .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<PaymentNotesOutsideBean>() {
                        @Override
                        public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                            super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                            CommUtils.checkMaterialDialog(materialDialog);
                            methodNotSuccessData(what_method, serverCode, serverMessage);

                        }
                    })).doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(Disposable disposable) throws Throwable {

//                        CommUtils.checkMaterialDialog(materialDialog);
                            method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_LOADING);
                            loadingGone();

                            setEnableLoadmore(refreshLayoutInPaymentFeeNotes, true);

                        }
                    }).subscribe(new Consumer<PaymentNotesOutsideBean>() {
                        @Override
                        public void accept(PaymentNotesOutsideBean paymentNotesOutsideBean) throws Throwable {

                            CommUtils.checkMaterialDialog(materialDialog);

                            method_handler_success(paymentNotesOutsideBean);

                        }
                    }, new ErrorConsumer() {

                        @Override
                        protected void error(ApiException apiException) {

                            CommUtils.checkMaterialDialog(materialDialog);

                            //页面报错；
                            if (apiException != null) {
                                if (!TextUtils.isEmpty(apiException.getDisplayMessage())) {
                                    ToastUtils.showShort(apiException.getDisplayMessage());
                                }
                            }
                        }
                    });

        } else if (flag_jumpfrom_where == FeeLiveOtherType.TYPE_RENTAL.getIndex()) {

            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "TYPE_RENTAL-租赁费");

            HashMap<String, Object> map = new HashMap<>();
            map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());

//        map.put(Parameterkey.appointDate, appointDate_upLoad);
//        map.put(Parameterkey.appointDate, TimeUtils.date2String(TimeUtils.getNowDate(), TimeUtilSer.simplemore));

            AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
            addLogUpLoadInfo.setActivity(mActivityInstance);
            addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETRECEIPTLISTFORWECHAT_URL);
            addLogUpLoadInfo.setUrlPath(ApiService.getReceiptListForWechat_url);
            addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);
            addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
            addLogUpLoadInfo.setHashMapParameter(map);

            NetworkManager.getInstance().initRetrofitRxJava()
                    .create(ApiService.class)
                    .getReceiptListForWechat(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                            MediaType.parse(ApiService.HEADER_JSON)))
                    .compose(PaymentNotesActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                    .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<PaymentNotesOutsideBean>() {
                        @Override
                        public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                            super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                            CommUtils.checkMaterialDialog(materialDialog);
                            methodNotSuccessData(what_method, serverCode, serverMessage);

                        }
                    })).doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(Disposable disposable) throws Throwable {

//                        CommUtils.checkMaterialDialog(materialDialog);

                            method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_LOADING);
                            loadingGone();

                            setEnableLoadmore(refreshLayoutInPaymentFeeNotes, true);

                        }
                    }).subscribe(new Consumer<PaymentNotesOutsideBean>() {
                        @Override
                        public void accept(PaymentNotesOutsideBean paymentNotesOutsideBean) throws Throwable {

                            CommUtils.checkMaterialDialog(materialDialog);

                            method_handler_success(paymentNotesOutsideBean);

                        }
                    }, new ErrorConsumer() {

                        @Override
                        protected void error(ApiException apiException) {

                            CommUtils.checkMaterialDialog(materialDialog);
                            function_apiException(apiException);
                        }
                    });

        } else if (flag_jumpfrom_where == FeeLiveOtherType.TYPE_ELECTRIC.getIndex()) {

            //如果是电费 过来的
//            FeeLiveOtherType {
//                        TYPE_PROPERTY(1, "物业费"),//
//                        TYPE_RENTAL(2, "租赁费"),
//                        TYPE_SUBMIT_REPAIR(3, "物业报修"),
//                        TYPE_ELECTRIC(4, "电费"),
//                        TYPE_WATER(5, "水费"),
//                        TYPE_CAR_PLACE(6, "车位管理");//

            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "TYPE_ELECTRIC-电费缴费 ");

            HashMap<String, Object> map = new HashMap<>();
            map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());
            map.put(Parameterkey.receiptClassify, FeeLiveReceiptClassify.RECEIPT_CLASSIFY_ELECTRIC.getIndex());//电费
//        map.put(Parameterkey.appointDate, appointDate_upLoad);
//        map.put(Parameterkey.appointDate, TimeUtils.date2String(TimeUtils.getNowDate(), TimeUtilSer.simplemore));

            AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
            addLogUpLoadInfo.setActivity(mActivityInstance);
            addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETRECEIPTLISTFORREMOTE_URL);//请求数字标识
            addLogUpLoadInfo.setUrlPath(ApiService.getReceiptListForRemote_url);//url地址
            addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
            addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
            addLogUpLoadInfo.setHashMapParameter(map);

            NetworkManager.getInstance().initRetrofitRxJava()
                    .create(ApiService.class)
                    .getReceiptListForRemote(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                            MediaType.parse(ApiService.HEADER_JSON)))
                    .compose(PaymentNotesActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                    .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<PaymentNotesOutsideBean>() {
                        @Override
                        public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                            super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                            CommUtils.checkMaterialDialog(materialDialog);
                            methodNotSuccessData(what_method, serverCode, serverMessage);

                        }
                    })).doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(Disposable disposable) throws Throwable {

//                        CommUtils.checkMaterialDialog(materialDialog);
                            method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_LOADING);

                            loadingGone();

                            setEnableLoadmore(refreshLayoutInPaymentFeeNotes, true);

                        }
                    }).subscribe(new Consumer<PaymentNotesOutsideBean>() {
                        @Override
                        public void accept(PaymentNotesOutsideBean paymentNotesOutsideBean) throws Throwable {

                            CommUtils.checkMaterialDialog(materialDialog);

                            method_handler_success(paymentNotesOutsideBean);

                        }
                    }, new ErrorConsumer() {

                        @Override
                        protected void error(ApiException apiException) {

                            CommUtils.checkMaterialDialog(materialDialog);

                            function_apiException(apiException);
                        }
                    });


        } else if (flag_jumpfrom_where == FeeLiveOtherType.TYPE_WATER.getIndex()) {

            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "TYPE_WATER--水费缴费 ");

            HashMap<String, Object> map = new HashMap<>();
            map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());
            map.put(Parameterkey.receiptClassify, FeeLiveReceiptClassify.RECEIPT_CLASSIFY_WATER.getIndex());//电费
//        map.put(Parameterkey.appointDate, appointDate_upLoad);
//        map.put(Parameterkey.appointDate, TimeUtils.date2String(TimeUtils.getNowDate(), TimeUtilSer.simplemore));

            AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
            addLogUpLoadInfo.setActivity(mActivityInstance);
            addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETRECEIPTLISTFORREMOTE_URL);//请求数字标识
            addLogUpLoadInfo.setUrlPath(ApiService.getReceiptListForRemote_url);//url地址
            addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
            addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
            addLogUpLoadInfo.setHashMapParameter(map);

            NetworkManager.getInstance().initRetrofitRxJava()
                    .create(ApiService.class)
                    .getReceiptListForRemote(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                            MediaType.parse(ApiService.HEADER_JSON)))
                    .compose(PaymentNotesActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                    .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<PaymentNotesOutsideBean>() {
                        @Override
                        public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                            super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                            CommUtils.checkMaterialDialog(materialDialog);
                            methodNotSuccessData(what_method, serverCode, serverMessage);

                        }
                    })).doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(Disposable disposable) throws Throwable {

//                        CommUtils.checkMaterialDialog(materialDialog);
                            method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_LOADING);

                            loadingGone();

                            setEnableLoadmore(refreshLayoutInPaymentFeeNotes, true);

                        }
                    }).subscribe(new Consumer<PaymentNotesOutsideBean>() {
                        @Override
                        public void accept(PaymentNotesOutsideBean paymentNotesOutsideBean) throws Throwable {

                            CommUtils.checkMaterialDialog(materialDialog);

                            method_handler_success(paymentNotesOutsideBean);

                        }
                    }, new ErrorConsumer() {

                        @Override
                        protected void error(ApiException apiException) {

                            CommUtils.checkMaterialDialog(materialDialog);

                            function_apiException(apiException);
                        }
                    });

        }

    }

    //物业费和租赁费通用的
    private void method_handler_success(PaymentNotesOutsideBean paymentNotesOutsideBean) {

        if (paymentNotesOutsideBean != null) {

            //实际获取的数据列表
            ArrayList<PaymentNotesBean> paymentNotesBeanArrayList = paymentNotesOutsideBean.getDataList();

            if (paymentNotesBeanArrayList != null && !paymentNotesBeanArrayList.isEmpty()) {

                if (mDatasResources != null) {
                    mDatasResources.addAll(paymentNotesBeanArrayList);
                }

            }

            //这里也不用管是下拉刷新或者上拉加载更多，直接判断是否为空，
            if (mDatasResources != null && mDatasResources.isEmpty()) {
                //同时禁用加载更多；
                fillNullDataView(StringUtils.getString(R.string.nulldatanow), R.drawable.errorsear);
                setEnableLoadmore(refreshLayoutInPaymentFeeNotes, false);
            }

            if (paymentNotesAdapter != null) {
                paymentNotesAdapter.notifyDataSetChanged();
            }

            //给分页值
            pagination_upLoad = paymentNotesOutsideBean.getNextPagination();

            //对列表改造：
            if (pagination_upLoad == Parameterkey.GET_NEXT_PAGINATION) {
                setFinishLoadMoreWithNoMoreData(refreshLayoutInPaymentFeeNotes, true);
            } else {
                setEnableLoadmore(refreshLayoutInPaymentFeeNotes, true);
            }

        }
    }

    @Override
    public void methodNotSuccessData(int what_method, String serverCode, String serverMessage) {
        super.methodNotSuccessData(what_method, serverCode, serverMessage);

        switch (what_method) {

            case ConstantApi.WHAT_GETRECEIPTLISTFORREMOTE_URL: {

                if (mDatasResources != null && mDatasResources.isEmpty()) {

                    setEnableLoadmore(refreshLayoutInPaymentFeeNotes, false);

                    CommUtils.checkCurrently((ErrorActivity) mActivityInstance,//
                            serverCode,//
                            R.drawable.errorsear,//
                            serverMessage,//
                            getString(R.string.nulldatanow));

                }

                break;
            }

            case ConstantApi.WHAT_GETRECEIPTLISTFORWECHAT_URL: {

                if (mDatasResources != null && mDatasResources.isEmpty()) {

                    setEnableLoadmore(refreshLayoutInPaymentFeeNotes, false);

                    CommUtils.checkCurrently((ErrorActivity) mActivityInstance,//
                            serverCode,//
                            R.drawable.errorsear,//
                            serverMessage,//
                            getString(R.string.nulldatanow));

                }

                break;
            }

            default:
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        if (mDatasResources != null && !mDatasResources.isEmpty()) {
            mDatasResources.clear();
//            mDataResources = null;
        }

        if (paymentNotesAdapter != null) {
            paymentNotesAdapter.notifyDataSetChanged();
            paymentNotesAdapter = null;
        }

        if (mDatasResources != null) {
            mDatasResources = null;
        }

    }

    @Override
    protected void methodBack() {

        methodBackFinish();

    }

    @Override
    public void processExtraData() {

        //use the data received here
        Bundle bundle = this.getIntent().getExtras();

        if (bundle != null) {

//            LogUtils.d(ConstantSign.LOGCAT_NOMAL + extra_jumpfrom_where);
            //
//            extra_repair_manage_item_bean = bundle.getParcelable(ExtraKey.EXTRA_REPAIR_MANAGE_ITEM_BEAN);
            flag_jumpfrom_where = bundle.getInt(ExtraKey.EXTRA_JUMPFROM_WHERE);

//            LogUtils.json(ConstantSign.LOGCAT_NOMAL, extra_repair_manage_item_bean);

        }


    }
}